package backend.service.search;

import org.springframework.stereotype.Component;
import query_understanding.query_language.doc_entity_tree.DocumentQueryTree;
import query_understanding.query_understand.tree_progress.DocumentQueryProgress;
import query_understanding.query_understand.tree_selector.QueryTreeSelector;
import semantic_matching.common.schema.MatchedDocumentTree;
import semantic_matching.doc_search.doc_tree.DocumentQueryMatcher;

/**
 * Created by julianzliu on 4/25/2017.
 */

@Component
public class SemanticFulltextSearchService {


    private QueryTreeSelector treeSelector;
    private DocumentQueryMatcher documentMatcher;


    public SemanticFulltextSearchService(){
        this.documentMatcher = new DocumentQueryMatcher();
        this.treeSelector = new QueryTreeSelector();
    }



    public String search(String query){
        DocumentQueryProgress progress = this.treeSelector.genDocQueryTree(query);

        MatchedDocumentTree matchedDocuments = this.documentMatcher.solveDocumentQueryProgress( progress );

        return null;

    }


    public String searchJsonResult(String query) {
        String result = this.search( query );

        String json = String.format("{'result' : '%s' }", result.toString() );

        return json;
    }

}
